<template>
	<div>
		<template v-if='!isFiltrate'>
			<div class="header">
				<div class="header-center">篮球数据</div>
				<div class="header-right iconfont" @click.stop='isFiltrate = !isFiltrate'>&#xe601;</div>
			</div>
			<home-nav  :type='type'></home-nav>
			<home-list :list='gameList' style="margin-bottom:1.33rem"></home-list>
			<home-footer :hover="currentItem"></home-footer>
			</template>
		<template v-else>
			<home-filtrate :list='opList' :type='type'  @handcheckList='handcheckListEvent'></home-filtrate>
		</template>
	</div>	
</template>
<script>
import HomeNav from './components/Nav'
import HomeList from './components/List_lq'
import HomeFooter from './components/Footer'
import HomeFiltrate from './components/filtrate'
import axios from 'axios'
import { Toast,Indicator  } from 'mint-ui'
import { socket } from 'jss/home/webSocket_lq.js'
export default {
	name: 'Home',
	components:{
		HomeNav,
		HomeList,
		HomeFooter,
		HomeFiltrate
	},
	data:function(){
		return {
			AllcheckList:[],
			currentItem:"3",
			AllgameList:[],
			gameList:[],
			type:"lq",
			isFiltrate:false,
		}
	},
	methods:{
		getHomeInfo:function(){
			Indicator.open({
			  text: '加载中···',
			  spinnerType: 'fading-circle'
			});
          	axios.get('/api/allMatch.php?sportType=23')
            .then(this.getHomeInfoSucc)
            .catch(function (error) {
                console.log(error);
              });
        },
        getHomeInfoSucc:function(res){
          res = res.data
          if (res.status == 0 && res.data) {
            const Fdata = res.data.f //所有结束的比赛信息
            const Idata = res.data.i //所有正在进行中的比赛信息
            const Ndata = res.data.n //所有未开始的比赛信息
            const Cdata = res.data.c //所有取消的比赛信息
            const IrCdata = res.data.ir //所有取消的比赛信息

            const opList = res.data.op //所有联赛信息
            this.AllgameList = Idata.concat(Ndata,Fdata,IrCdata,Cdata)
            this.gameList = this.AllgameList
            this.opList = opList
            Indicator.close();
          }
        },
        handcheckListEvent(list){
        	this.isFiltrate = !this.isFiltrate
        	var newList = [];
        	this.AllgameList.forEach(function(item,i) {
	       		if (list.indexOf(item.tournament_stage_id) > -1) {
	       			newList.push(item)
	       		} 
	       	})
		    this.gameList = newList;
        }	
	},
	created () {
		this.getHomeInfo();
	},
	mounted(){
		
		
	},
	activated () {}
};
</script>
<style lang="less" scoped>
	@import '~styles/header.less';
</style>
